package com.itheima.mapper;

import com.itheima.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper  // 表示当前接口在运行时会自动创建实现类对象并交给IOC容器管理
public interface DeptMapper {

//    @Select("select * from dept order by update_time DESC ")  // 此时使用了xml文件进行映射并使用sql查询
    List<Dept> findAll();


    @Delete("delete from dept where id = #{id}")
    void deleteById(Integer id);

    @Insert("insert into dept(name, create_time, update_time) values (#{name}, #{createTime}, #{updateTime})")
    void save(Dept dept);


    @Select("select  id, name, create_time, update_time from dept where id = #{id}")
    Dept selectById(Integer id);

    @Update("update dept set name = #{name}, update_time = #{updateTime} where id = #{id}")
    void update(Dept dept);


}
